//
//  DepositsHistoryVC.m
//  HengYouCai
//
//  Created by ycgwl on 2017/5/2.
//  Copyright © 2017年 lwj. All rights reserved.
//

#import "DepositsHistoryVC.h"
// 募集中
#import "RaiseViewController.h"
#import "HengYouCai-Swift.h"
@interface DepositsHistoryVC ()<PageTitleViewDelegate,PageContentViewDelegate>
@property(nonatomic,strong)NSMutableArray *titlesArray;
@property(nonatomic,strong)NSMutableArray *contentVCArray;
@property(nonatomic, retain)PageTitleView *pageTitleView;
@property(nonatomic, retain)PageContentView *pageContentView;
@end

@implementation DepositsHistoryVC

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.titleName;//@"投资记录";

    self.view.backgroundColor = [UIColor whiteColor];
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    self.contentVCArray = [NSMutableArray array];
    self.titlesArray = [NSMutableArray array];
    [self getTypeList];
  
    
}
- (void)setUI{
    [self.view addSubview:self.pageTitleView];
    [self.view addSubview:self.pageContentView];
}
- (void)getTypeList{
    WLGetWeakSelf(weakSelf, self);
    [self.view showHUDLoading];
    
    [HYCNetService getMyWalletaTradeTypeListOnSuccess:^(NSDictionary *dictResult) {
        [weakSelf.view hideHUDLoading:0];
        NSArray *arr = dictResult[@"cdkeyTypeList"];
        for (NSDictionary *typeDic in arr) {
            /**内容*/
            UIStoryboard *story = [UIStoryboard storyboardWithName:@"Profile" bundle:nil];
                RaiseViewController *raise = [story instantiateViewControllerWithIdentifier:@"RaiseViewControllerID"];
                raise.orderStatus = [NSString stringWithFormat:@"%@",typeDic[@"status"]];
                [self.titlesArray addObject:typeDic[@"title"]];
                [self.contentVCArray addObject:raise];
        }
        [weakSelf setUI];
    } andFailed:^(NSInteger code, NSString *errorMsg) {
        [weakSelf.view showHUDFailTips:errorMsg hideDelay:kHUDHideDelay];
    }];
    
}
- (void)pageTitleView:(PageTitleView *)titleView selectedIndex:(NSInteger)index
{
    [_pageContentView setCurrentIndex:index];
}
- (void)pageContentView:(PageContentView *)contentView progress:(CGFloat)progress sourceIndex:(NSInteger)sourceIndex targetIndex:(NSInteger)targetIndex
{
    [_pageTitleView setTitleWithProgress:progress sourceIndex:sourceIndex targetIndex:targetIndex];
}
#pragma 懒加载
- (PageTitleView *)pageTitleView
{
    if (!_pageTitleView) {
        
        /**
         标题栏
         */
        _pageTitleView = [[PageTitleView alloc] initWithFrame:CGRectMake(0, kJcwGetNavHeight(), f_Device_w, 40) titles:self.titlesArray];
        _pageTitleView.delegate = self;
        _pageTitleView.backgroundColor = [UIColor whiteColor];
    }
    return _pageTitleView;
}
- (PageContentView *)pageContentView
{
    if (!_pageContentView) {
       
        
//        RepaymentViewController *repayment = [story instantiateViewControllerWithIdentifier:@"RepaymentViewControllerID"];
//        FinishViewController *finish = [story instantiateViewControllerWithIdentifier:@"FinishViewControllerID"];

        CGRect rect = CGRectMake(0, kJcwGetNavHeight()+40+10, f_Device_w, f_Device_h-(kJcwGetNavHeight()+40+10));
        
        _pageContentView = [[PageContentView alloc] initWithFrame:rect childVcs:self.contentVCArray parentViewController:self];
        _pageContentView.delegate = self;
    }
    return _pageContentView;
}
@end
